#ifndef __TREE_HANDLER_H__
#define __TREE_HANDLER_H__

//#include "../../bstree/src/bstree.h"
#include "bsTreeExtended.h"
#include "wordcontainer.h"
#include "bstreeregisterclasses.h"
#include "frontcodingmanager.h"


namespace invertedindex{

class TreeHandler{
	private:
		unsigned int BLOCK_SIZE;
		unsigned int REGISTER_MAX_SIZE;
	private:
		KeyValFactory kvf;
		KeyKeyValFactory kkvf;
		BSTreeExtended bsharpTree;
	public:
		TreeHandler(const std::string& confPath);
		~TreeHandler();
		
		bool getWord(WordContainer& thdata);
		bool insertWord(const WordContainer& thdata);
		bool modifyWordBlockPointer(const WordContainer& thdata);

		void toOstream(std::ostream& out);

		std::ostream& printTreeBlock(std::ostream& out, unsigned int offset);
		
	private:
		unsigned int getNodeSize(const std::string& confPath);
};

}


#endif
